In [2]:
import pandas as pd
In [3]:
labour_force = pd. read_excel("Labor force data.xlsx")
In [4]:
labour_force.head()
Out[4]:
State Labour Force Population
0 NaN NaN
1 Abia 1.919458e+06
2 Adamawa 1.445800e+06
3 Akwa Ibom 3.217171e+06
4 Anambra 3.009646e+06
In [5]:
labour_force.drop(index=0,axis=0,inplace=True)
In [6]:
labour_force.head()
Out[6]:
State Labour Force Population
1 Abia 1.919458e+06
2 Adamawa 1.445800e+06
3 Akwa Ibom 3.217171e+06
4 Anambra 3.009646e+06
5 Bauchi 1.825977e+06
In [7]:
labour_force.dtypes
Out[7]:
State                        object
Labour Force Population     float64
dtype: object
In [8]:
import plotly.graph_objs as go
import plotly.express as px
import plotly.io as pio
In [9]:
fig = px.bar(labour_force, y = 'State', x = 'Labour Force Population ', orientation = 'h', color = 'Labour Force Population ', text = 'Labour Force Population ')
fig.update_traces(texttemplate='%{text:.2s}', textposition='outside')
fig.update_layout(uniformtext_minsize=8, uniformtext_mode='hide')
fig.update_layout(
    title={
        'text':"Labour Force Per State For Q1 in 2017",
        'y':0.95,
        'x':0.5,
        'xanchor': 'center',
        'yanchor': 'top'}, template = "seaborn", height = 900, width =900)
In [10]:
import json
In [11]:
nigeria_states = json.load(open("nigeria_geojson.geojson", "r"))
In [12]:
nigeria_states["features"][0]["properties"].keys()
Out[12]:
dict_keys(['objectid', 'statecode', 'state', 'capcity', 'source', 'timestamp', 'globalid', 'shape_area', 'shape_len', 'geozone', 'cartodb_id', 'created_at', 'updated_at'])
In [13]:
state_id_map = {}
for feature in nigeria_states["features"]:
    feature["id"] = feature["properties"]["statecode"]
    state_id_map[feature["properties"]["state"]] = feature["id"]
In [14]:
labour_force["id"] = labour_force["State"].apply(lambda x: state_id_map[x])
In [16]:
fig = px.choropleth(labour_force, geojson=nigeria_states, locations='id', color='Labour Force Population ',scope = "africa", hover_name = "State", hover_data = ["State"])
fig.update_geos(fitbounds="locations", visible=False)
fig.show()
In [ ]: